package com.ruoyi.web.controller.zbj;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.zbj.domain.RyLts;
import com.ruoyi.zbj.service.IRyLtsService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 聊天室管理Controller
 * 
 * @author lps
 * @date 2024-11-11
 */
@Controller
@RequestMapping("/zbj/lts")
public class RyLtsController extends BaseController
{
    private String prefix = "zbj/lts";

    @Autowired
    private IRyLtsService ryLtsService;

    @RequiresPermissions("zbj:lts:view")
    @GetMapping()
    public String lts()
    {
        return prefix + "/lts";
    }

    /**
     * 查询聊天室管理列表
     */
    @RequiresPermissions("zbj:lts:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(RyLts ryLts)
    {
        startPage();
        List<RyLts> list = ryLtsService.selectRyLtsList(ryLts);
        return getDataTable(list);
    }

    /**
     * 导出聊天室管理列表
     */
    @RequiresPermissions("zbj:lts:export")
    @Log(title = "聊天室管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(RyLts ryLts)
    {
        List<RyLts> list = ryLtsService.selectRyLtsList(ryLts);
        ExcelUtil<RyLts> util = new ExcelUtil<RyLts>(RyLts.class);
        return util.exportExcel(list, "聊天室管理数据");
    }

    /**
     * 新增聊天室管理
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存聊天室管理
     */
    @RequiresPermissions("zbj:lts:add")
    @Log(title = "聊天室管理", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(RyLts ryLts)
    {
        return toAjax(ryLtsService.insertRyLts(ryLts));
    }

    /**
     * 修改聊天室管理
     */
    @RequiresPermissions("zbj:lts:edit")
    @GetMapping("/edit/{title}")
    public String edit(@PathVariable("title") String title, ModelMap mmap)
    {
        RyLts ryLts = ryLtsService.selectRyLtsByTitle(title);
        mmap.put("ryLts", ryLts);
        return prefix + "/edit";
    }

    /**
     * 修改保存聊天室管理
     */
    @RequiresPermissions("zbj:lts:edit")
    @Log(title = "聊天室管理", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(RyLts ryLts)
    {
        return toAjax(ryLtsService.updateRyLts(ryLts));
    }

    /**
     * 删除聊天室管理
     */
    @RequiresPermissions("zbj:lts:remove")
    @Log(title = "聊天室管理", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(ryLtsService.deleteRyLtsByTitles(ids));
    }
}
